<include file="Common:header"/>
<style>
.click-more{
	padding-top:5px
}
</style>
<body>
	<div class="top-wrap" style="padding-top: 15px; padding-bottom:15px;">
		<div class="top-btn-group">
			<a href="<{:U('Home/User/upstream')}>" class="top-btn">求助上级代理</a>
			<a href="<{:U('Home/User/agentCenter')}>" class="top-btn" style="float:right; margin-right:0;">第 <{$downLayer - 1}> 级会员</a>
		</div>
		<div class="title-bg">推广数据明细</div>
	</div>
	<div class="main-wrap" style="padding-top:10px;">
		<if condition="$user_list">
		<foreach name="user_list" item="row">
		
		<div class="top-border-box" style="margin-bottom:10px; <if condition="$row['level'] != 0">border-top-color: gold;</if>" >
			<div class="agent-box">
				<p>会员名：<{$row['username']}></p>
				<p>微信号：<{$row['weixin']}></p>
				<p>注册：<{$row['strTime']}></p>
				<a href="<{:U('Home/User/agentCenter','',false)}>/uid/<{$row['id']}>/downLayer/<{$downLayer}>" class="agent-down">下级</a>
			
				<if condition="$row['level'] != 0">
					<p class="vip-tag"><{:C('user_info.member_tips')}></p>
				</if>
			</div>
		</div>
		</foreach>
		<div class="click-more" data-page="2" onclick="loadMore($(this))">点击加载更多</div>
		<else />
		<div class="nodata-box" >
			<if condition="$member_info['level'] || $judge_member">
				<notempty name="username">
				会员 [<{$username}>]
				</notempty>
				暂无下线会员
			<else />
				非付费会员不能查看下线会员
			</if>
		</div>
		</if>
	</div>

<include file="Common:menu"/>
</body>
</html>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script>

var loadImgHtml = '<img src="__PUBLIC__/js/layer/skin/default/loading-0.gif" />';
function loadMore(obj) {
	// 加载页码
	var page = obj.attr('data-page');
	var data = {
		'page':page,
		'uid':<{$uid}>,
		'downLayer':<{$downLayer}>,
	};
	// 替换内容成为加载图
	obj.html(loadImgHtml);

	$.post('<{:U('Home/User/agentCenter')}>',data,function(index){
		if (index.status == 1) {
			obj.attr('data-page',index.page);
			if (index.user_list)
			{
				$.each(index.user_list, function(key, row) {
				if(row.level != 0){
					var css = 'margin-bottom:10px;border-top-color: gold;';
				}else{
					var css = 'margin-bottom:10px;';
				}
				
				var html = '<div class="top-border-box" style="'+css+'"><div class="agent-box">';
					html += '<p>会员名：'+row.username+'</p>';
					html += '<p>微信号：'+row.weixin+'</p>';
					html += '<p>注册：'+row.strTime+'</p><a href="<{:U('Home/User/agentCenter','',false)}>/uid/'+row.id+'/downLayer/<{$downLayer}>" class="agent-down">下级</a>';
					if (<?php echo $member_info['super_agent'] == 1 ? 'true' : 'false'; ?> && row.level == 0) {
						html += '<a href="javascript:void(0);" class="agent-del" onclick="deleteUser($(this))" data-uid="'+row.id+'" data-name="'+row.username+'" >删除</a>';
					}
					if(row.level != 0){
						html +='<p class="vip-tag"><{:C('user_info.member_tips')}></p>';
					}
					html += '</div></div>';
			
					obj.before(html);
				});
				obj.html('点击加载更多');
			}
			else
			{
				obj.html('<font color="grey">已经没有更多</font>');
				setTimeout(function(){
					obj.fadeOut('2000');
				},1000);
			}

		} else {
			obj.html('点击加载更多');
			layer.msg('加载失败');
		}
	});
}
</script> 
<script>
	(function($) {
    $.extend({
        myTime: {
            /**
             * 当前时间戳
             * @return <int>        unix时间戳(秒)  
             */
            CurTime: function(){
                return Date.parse(new Date())/1000;
            },
            /**              
             * 日期 转换为 Unix时间戳
             * @param <string> 2014-01-01 20:20:20  日期格式              
             * @return <int>        unix时间戳(秒)              
             */
            DateToUnix: function(string) {
                var f = string.split(' ', 2);
                var d = (f[0] ? f[0] : '').split('-', 3);
                var t = (f[1] ? f[1] : '').split(':', 3);
                return (new Date(
                        parseInt(d[0], 10) || null,
                        (parseInt(d[1], 10) || 1) - 1,
                        parseInt(d[2], 10) || null,
                        parseInt(t[0], 10) || null,
                        parseInt(t[1], 10) || null,
                        parseInt(t[2], 10) || null
                        )).getTime() / 1000;
            },
            /**              
             * 时间戳转换日期              
             * @param <int> unixTime    待时间戳(秒)              
             * @param <bool> isFull    返回完整时间(Y-m-d 或者 Y-m-d H:i:s)              
             * @param <int>  timeZone   时区              
             */
            UnixToDate: function(unixTime, isFull, timeZone) {
                if (typeof (timeZone) == 'number')
                {
                    unixTime = parseInt(unixTime) + parseInt(timeZone) * 60 * 60;
                }
                var time = new Date(unixTime * 1000);
                var ymdhis = "";
                ymdhis += time.getUTCFullYear() + "-";
                ymdhis += (time.getUTCMonth()+1) + "-";
                ymdhis += time.getUTCDate();
                if (isFull === true)
                {
                    ymdhis += " " + time.getUTCHours() + ":";
                    ymdhis += time.getUTCMinutes() + ":";
                    ymdhis += time.getUTCSeconds();
                }
                return ymdhis;
            }
        }
    });
})(jQuery);
/* 时间戳与日期转换----调用实例 */
/*
console.log($.myTime.DateToUnix('2014-5-15 20:20:20'));
console.log($.myTime.UnixToDate(1325347200));  
*/

</script>